home *** CD-ROM | disk | FTP | other *** search
/ United Public Domain Gold 2 / United Public Domain Gold 2.iso / utilities / pu619.dms / pu619.adf / Utilities / TASKE.LHA / Source / winhand.c < prev    next >
C/C++ Source or Header  |  1993-08-26  |  4KB  |  150 lines

  1. /*
  2.  * Copyright (c) 1993 Michael D. Bayne.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without modification, are permitted provided that
  6.  * the following conditions are met:
  7.  *
  8.  * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
  9.  *    following disclaimer.
  10.  *
  11.  * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
  12.  *    following disclaimer in the documentation and/or other materials provided with the distribution.
  13.  *
  14.  * 3. All advertising materials mentioning features or use of this software must display the following
  15.  *    acknowledgement:
  16.  *
  17.  *       This product includes software developed by Michael D. Bayne.
  18.  *
  19.  * 4. My name may not be used to endorse or promote products derived from this software without specific prior
  20.  *    written permission.
  21.  *
  22.  * THIS SOFTWARE IS PROVIDED BY MICHAEL D. BAYNE ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
  23.  * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  24.  * IN NO EVENT SHALL MICHAEL D. BAYNE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  25.  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  26.  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  27.  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28.  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29.  */
  30.  
  31. #include <exec/execbase.h>
  32. #include <exec/memory.h>
  33.  
  34. #include <intuition/intuitionbase.h>
  35. #include <intuition/screens.h>
  36.  
  37. #include <libraries/gadtools.h>
  38.  
  39. #include <dos/dos.h>
  40.  
  41. #include "TaskE.h"
  42. #include "TaskE_rev.h"
  43. #include "defs.h"
  44.  
  45. extern    struct    List *taskList, *scrList;
  46. extern    struct    TagItem Tags[];
  47. extern    ULONG    killMode;
  48.  
  49. int TASKLClicked( void )
  50. {
  51.     ULONG    num;
  52.     struct    TaskNode *t;
  53.  
  54.     for( t = ( struct TaskNode * )taskList->lh_Head, num = 0; num != TaskEMsg.Code; num++,
  55.         t = ( struct TaskNode * )t->tn_Node.ln_Succ );
  56.  
  57.     switch( num = rtEZRequest( "Name: %s\nPriority: %02d\nAddress: 0x%08lx\nSigAlloc: 0x%08lx\nSigWait: 0x%08lx",
  58.         "Send _Break|_Remove Task|_Cancel", 0L, ( struct TagItem * )Tags, t->tn_Name, t->tn_Node.ln_Pri, t->tn_TaskAddress,
  59.         t->tn_SigAlloc, t->tn_SigWait )) {
  60.  
  61.     case 1:
  62.         sendSigAbrt( t );
  63.         if( TaskExists( t->tn_TaskAddress ))
  64.             rtEZRequest( "Task did not exit.", "_Ok", 0L, ( struct TagItem * )Tags );
  65.         else {
  66.             rtEZRequest( "Task exited succesfully.", "_Ok", 0L, ( struct TagItem * )Tags );
  67.             GT_SetGadgetAttrs( TaskEGadgets[GD_TASKL], TaskEWnd, 0l, GTLV_Labels, 0L, TAG_DONE );
  68.             Remove(( struct Node * )t );
  69.             FreeMem( t, sizeof( struct TaskNode ));
  70.             GT_SetGadgetAttrs( TaskEGadgets[GD_TASKL], TaskEWnd, 0l, GTLV_Labels, taskList, TAG_DONE );
  71.         }
  72.         break;
  73.     case 2:
  74.         if( TaskExists( t->tn_TaskAddress )) RemTask(( struct Task * )t->tn_TaskAddress );
  75.         GT_SetGadgetAttrs( TaskEGadgets[GD_TASKL], TaskEWnd, 0l, GTLV_Labels, 0L, TAG_DONE );
  76.         Remove(( struct Node * )t );
  77.         FreeMem( t, sizeof( struct TaskNode ));
  78.         GT_SetGadgetAttrs( TaskEGadgets[GD_TASKL], TaskEWnd, 0l, GTLV_Labels, taskList, TAG_DONE );
  79.         killMode = rtEZRequest( "Phew. Task successfully removed.", "Remove _Window|Remove _Screen|_Ok", 0L, Tags );
  80.         break;
  81.     }
  82.     return( 1 );
  83. }
  84.  
  85. int REBOOTClicked( void )
  86. {
  87.     ColdReboot();
  88.     return( 0 );
  89. }
  90.  
  91. int UPDATEClicked( void )
  92. {
  93.     getTasks( taskList );
  94.     return( 1 );
  95. }
  96.  
  97. int SCREENLClicked( void )
  98. {
  99.     popScreen( TaskEMsg.Code );
  100.     return( 1 );
  101. }
  102.  
  103. int TaskEABOUT( void )
  104. {
  105.     rtEZRequest( VSTRING"\nFree Software from Michael D. Bayne", "_Ok", 0L, ( struct TagItem * )Tags );
  106.     return( 1 );
  107. }
  108.  
  109. int TaskEQUIT( void )
  110. {
  111.     return( 0 );
  112. }
  113.  
  114. int TaskEKWND( void )
  115. {
  116.     killMode = WINDOW;
  117.     return( 1 );
  118. }
  119.  
  120. int TaskEKSCR( void )
  121. {
  122.     killMode = SCREEN;
  123.     return( 1 );
  124. }
  125.  
  126. int TaskECloseWindow( void )
  127. {
  128.     return( 0 );
  129. }
  130.  
  131. int TaskEActiveWindow( void )
  132. {
  133.     getScreens( scrList );
  134.     return( 1 );
  135. }
  136.  
  137. int TaskEVanillaKey( void )
  138. {
  139.     switch( TaskEMsg.Code ) {
  140.     case 'U':
  141.     case 'u':
  142.         return( UPDATEClicked() );
  143.     case 'R':
  144.     case 'r':
  145.         return( REBOOTClicked() );
  146.     case 27: /* ESC */
  147.         return( 0 );
  148.     }
  149. }
  150.